"""
演示使用pymysql库进行数据插入的操作
"""

from pymysql import Connection

# 构建MySQL数据库链接
conn = Connection(
    host="localhost",
    port=3306,
    user="root",
    password="123456",
    autocommit=True  # 自动提交
)

# 获取游标
cursor = conn.cursor()
# 选择数据库
conn.select_db("test")
# 执行插入SQL
cursor.execute("insert into student values (10001, '周杰轮', 31, '男')")
# 通过commit确认提交
# conn.commit()
# 关闭数据库链接
conn.close()
